# -*- coding:utf-8 -*-

"""
    PyTorch 模型转 wts 文件
"""

import struct
import torch

pt_file = "./weights/yolov5s.pt"
wts_file = "./para.wts"

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")


def main():
    # Load model
    model = torch.load(pt_file, map_location="cpu")['model'].float()  # load to FP32
    model.to(device).eval()

    print('model: ', model)
    tmp = torch.ones(1, 3, 640, 640).to(device)
    print('input: ', tmp)
    out = model(tmp)[0]
    print('output:', out)

    with open(wts_file, 'w') as f:
        f.write('{}\n'.format(len(model.state_dict().keys())))
        for k, v in model.state_dict().items():
            print("Key: ", k, " Value: ", v.shape, " To numpy shape: ", v.cpu().numpy().shape)
            vr = v.reshape(-1).cpu().numpy()
            f.write('{} {} '.format(k, len(vr)))
            for vv in vr:
                f.write(' ')
                f.write(struct.pack('>f' ,float(vv)).hex())
            f.write('\n')


if __name__ == '__main__':
    main()


"""
Key:  model.0.conv.conv.weight  Value:  torch.Size([32, 12, 3, 3])  To numpy shape:  (32, 12, 3, 3)
Key:  model.0.conv.bn.weight  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.0.conv.bn.bias  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.0.conv.bn.running_mean  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.0.conv.bn.running_var  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.0.conv.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.1.conv.weight  Value:  torch.Size([64, 32, 3, 3])  To numpy shape:  (64, 32, 3, 3)
Key:  model.1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.2.cv1.conv.weight  Value:  torch.Size([32, 64, 1, 1])  To numpy shape:  (32, 64, 1, 1)
Key:  model.2.cv1.bn.weight  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv1.bn.bias  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv1.bn.running_mean  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv1.bn.running_var  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.2.cv2.conv.weight  Value:  torch.Size([32, 64, 1, 1])  To numpy shape:  (32, 64, 1, 1)
Key:  model.2.cv2.bn.weight  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv2.bn.bias  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv2.bn.running_mean  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv2.bn.running_var  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.2.cv3.conv.weight  Value:  torch.Size([64, 64, 1, 1])  To numpy shape:  (64, 64, 1, 1)
Key:  model.2.cv3.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.2.cv3.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.2.cv3.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.2.cv3.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.2.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.2.m.0.cv1.conv.weight  Value:  torch.Size([32, 32, 1, 1])  To numpy shape:  (32, 32, 1, 1)
Key:  model.2.m.0.cv1.bn.weight  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv1.bn.bias  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv1.bn.running_mean  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv1.bn.running_var  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.2.m.0.cv2.conv.weight  Value:  torch.Size([32, 32, 3, 3])  To numpy shape:  (32, 32, 3, 3)
Key:  model.2.m.0.cv2.bn.weight  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv2.bn.bias  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv2.bn.running_mean  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv2.bn.running_var  Value:  torch.Size([32])  To numpy shape:  (32,)
Key:  model.2.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.3.conv.weight  Value:  torch.Size([128, 64, 3, 3])  To numpy shape:  (128, 64, 3, 3)
Key:  model.3.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.3.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.3.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.3.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.cv1.conv.weight  Value:  torch.Size([64, 128, 1, 1])  To numpy shape:  (64, 128, 1, 1)
Key:  model.4.cv1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.cv2.conv.weight  Value:  torch.Size([64, 128, 1, 1])  To numpy shape:  (64, 128, 1, 1)
Key:  model.4.cv2.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv2.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv2.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv2.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.cv3.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.4.cv3.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.4.cv3.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.4.cv3.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.4.cv3.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.4.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.m.0.cv1.conv.weight  Value:  torch.Size([64, 64, 1, 1])  To numpy shape:  (64, 64, 1, 1)
Key:  model.4.m.0.cv1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.m.0.cv2.conv.weight  Value:  torch.Size([64, 64, 3, 3])  To numpy shape:  (64, 64, 3, 3)
Key:  model.4.m.0.cv2.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv2.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv2.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv2.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.m.1.cv1.conv.weight  Value:  torch.Size([64, 64, 1, 1])  To numpy shape:  (64, 64, 1, 1)
Key:  model.4.m.1.cv1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.m.1.cv2.conv.weight  Value:  torch.Size([64, 64, 3, 3])  To numpy shape:  (64, 64, 3, 3)
Key:  model.4.m.1.cv2.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv2.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv2.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv2.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.1.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.m.2.cv1.conv.weight  Value:  torch.Size([64, 64, 1, 1])  To numpy shape:  (64, 64, 1, 1)
Key:  model.4.m.2.cv1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.4.m.2.cv2.conv.weight  Value:  torch.Size([64, 64, 3, 3])  To numpy shape:  (64, 64, 3, 3)
Key:  model.4.m.2.cv2.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv2.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv2.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv2.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.4.m.2.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.5.conv.weight  Value:  torch.Size([256, 128, 3, 3])  To numpy shape:  (256, 128, 3, 3)
Key:  model.5.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.5.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.5.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.5.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.5.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.cv1.conv.weight  Value:  torch.Size([128, 256, 1, 1])  To numpy shape:  (128, 256, 1, 1)
Key:  model.6.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.cv2.conv.weight  Value:  torch.Size([128, 256, 1, 1])  To numpy shape:  (128, 256, 1, 1)
Key:  model.6.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.cv3.conv.weight  Value:  torch.Size([256, 256, 1, 1])  To numpy shape:  (256, 256, 1, 1)
Key:  model.6.cv3.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.6.cv3.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.6.cv3.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.6.cv3.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.6.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.m.0.cv1.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.6.m.0.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.m.0.cv2.conv.weight  Value:  torch.Size([128, 128, 3, 3])  To numpy shape:  (128, 128, 3, 3)
Key:  model.6.m.0.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.m.1.cv1.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.6.m.1.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.m.1.cv2.conv.weight  Value:  torch.Size([128, 128, 3, 3])  To numpy shape:  (128, 128, 3, 3)
Key:  model.6.m.1.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.1.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.m.2.cv1.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.6.m.2.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.6.m.2.cv2.conv.weight  Value:  torch.Size([128, 128, 3, 3])  To numpy shape:  (128, 128, 3, 3)
Key:  model.6.m.2.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.6.m.2.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.7.conv.weight  Value:  torch.Size([512, 256, 3, 3])  To numpy shape:  (512, 256, 3, 3)
Key:  model.7.bn.weight  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.7.bn.bias  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.7.bn.running_mean  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.7.bn.running_var  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.7.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.8.cv1.conv.weight  Value:  torch.Size([256, 512, 1, 1])  To numpy shape:  (256, 512, 1, 1)
Key:  model.8.cv1.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.8.cv1.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.8.cv1.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.8.cv1.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.8.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.8.cv2.conv.weight  Value:  torch.Size([512, 1024, 1, 1])  To numpy shape:  (512, 1024, 1, 1)
Key:  model.8.cv2.bn.weight  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.8.cv2.bn.bias  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.8.cv2.bn.running_mean  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.8.cv2.bn.running_var  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.8.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.9.cv1.conv.weight  Value:  torch.Size([256, 512, 1, 1])  To numpy shape:  (256, 512, 1, 1)
Key:  model.9.cv1.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv1.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv1.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv1.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.9.cv2.conv.weight  Value:  torch.Size([256, 512, 1, 1])  To numpy shape:  (256, 512, 1, 1)
Key:  model.9.cv2.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv2.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv2.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv2.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.9.cv3.conv.weight  Value:  torch.Size([512, 512, 1, 1])  To numpy shape:  (512, 512, 1, 1)
Key:  model.9.cv3.bn.weight  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.9.cv3.bn.bias  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.9.cv3.bn.running_mean  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.9.cv3.bn.running_var  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.9.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.9.m.0.cv1.conv.weight  Value:  torch.Size([256, 256, 1, 1])  To numpy shape:  (256, 256, 1, 1)
Key:  model.9.m.0.cv1.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv1.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv1.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv1.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.9.m.0.cv2.conv.weight  Value:  torch.Size([256, 256, 3, 3])  To numpy shape:  (256, 256, 3, 3)
Key:  model.9.m.0.cv2.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv2.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv2.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv2.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.9.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.10.conv.weight  Value:  torch.Size([256, 512, 1, 1])  To numpy shape:  (256, 512, 1, 1)
Key:  model.10.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.10.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.10.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.10.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.10.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.13.cv1.conv.weight  Value:  torch.Size([128, 512, 1, 1])  To numpy shape:  (128, 512, 1, 1)
Key:  model.13.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.13.cv2.conv.weight  Value:  torch.Size([128, 512, 1, 1])  To numpy shape:  (128, 512, 1, 1)
Key:  model.13.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.13.cv3.conv.weight  Value:  torch.Size([256, 256, 1, 1])  To numpy shape:  (256, 256, 1, 1)
Key:  model.13.cv3.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.13.cv3.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.13.cv3.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.13.cv3.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.13.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.13.m.0.cv1.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.13.m.0.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.13.m.0.cv2.conv.weight  Value:  torch.Size([128, 128, 3, 3])  To numpy shape:  (128, 128, 3, 3)
Key:  model.13.m.0.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.13.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.14.conv.weight  Value:  torch.Size([128, 256, 1, 1])  To numpy shape:  (128, 256, 1, 1)
Key:  model.14.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.14.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.14.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.14.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.14.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.17.cv1.conv.weight  Value:  torch.Size([64, 256, 1, 1])  To numpy shape:  (64, 256, 1, 1)
Key:  model.17.cv1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.17.cv2.conv.weight  Value:  torch.Size([64, 256, 1, 1])  To numpy shape:  (64, 256, 1, 1)
Key:  model.17.cv2.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv2.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv2.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv2.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.17.cv3.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.17.cv3.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.17.cv3.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.17.cv3.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.17.cv3.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.17.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.17.m.0.cv1.conv.weight  Value:  torch.Size([64, 64, 1, 1])  To numpy shape:  (64, 64, 1, 1)
Key:  model.17.m.0.cv1.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv1.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv1.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv1.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.17.m.0.cv2.conv.weight  Value:  torch.Size([64, 64, 3, 3])  To numpy shape:  (64, 64, 3, 3)
Key:  model.17.m.0.cv2.bn.weight  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv2.bn.bias  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv2.bn.running_mean  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv2.bn.running_var  Value:  torch.Size([64])  To numpy shape:  (64,)
Key:  model.17.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.18.conv.weight  Value:  torch.Size([128, 128, 3, 3])  To numpy shape:  (128, 128, 3, 3)
Key:  model.18.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.18.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.18.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.18.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.18.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.20.cv1.conv.weight  Value:  torch.Size([128, 256, 1, 1])  To numpy shape:  (128, 256, 1, 1)
Key:  model.20.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.20.cv2.conv.weight  Value:  torch.Size([128, 256, 1, 1])  To numpy shape:  (128, 256, 1, 1)
Key:  model.20.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.20.cv3.conv.weight  Value:  torch.Size([256, 256, 1, 1])  To numpy shape:  (256, 256, 1, 1)
Key:  model.20.cv3.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.20.cv3.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.20.cv3.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.20.cv3.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.20.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.20.m.0.cv1.conv.weight  Value:  torch.Size([128, 128, 1, 1])  To numpy shape:  (128, 128, 1, 1)
Key:  model.20.m.0.cv1.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv1.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv1.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv1.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.20.m.0.cv2.conv.weight  Value:  torch.Size([128, 128, 3, 3])  To numpy shape:  (128, 128, 3, 3)
Key:  model.20.m.0.cv2.bn.weight  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv2.bn.bias  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv2.bn.running_mean  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv2.bn.running_var  Value:  torch.Size([128])  To numpy shape:  (128,)
Key:  model.20.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.21.conv.weight  Value:  torch.Size([256, 256, 3, 3])  To numpy shape:  (256, 256, 3, 3)
Key:  model.21.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.21.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.21.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.21.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.21.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.23.cv1.conv.weight  Value:  torch.Size([256, 512, 1, 1])  To numpy shape:  (256, 512, 1, 1)
Key:  model.23.cv1.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv1.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv1.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv1.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.23.cv2.conv.weight  Value:  torch.Size([256, 512, 1, 1])  To numpy shape:  (256, 512, 1, 1)
Key:  model.23.cv2.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv2.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv2.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv2.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.23.cv3.conv.weight  Value:  torch.Size([512, 512, 1, 1])  To numpy shape:  (512, 512, 1, 1)
Key:  model.23.cv3.bn.weight  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.23.cv3.bn.bias  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.23.cv3.bn.running_mean  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.23.cv3.bn.running_var  Value:  torch.Size([512])  To numpy shape:  (512,)
Key:  model.23.cv3.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.23.m.0.cv1.conv.weight  Value:  torch.Size([256, 256, 1, 1])  To numpy shape:  (256, 256, 1, 1)
Key:  model.23.m.0.cv1.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv1.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv1.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv1.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv1.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.23.m.0.cv2.conv.weight  Value:  torch.Size([256, 256, 3, 3])  To numpy shape:  (256, 256, 3, 3)
Key:  model.23.m.0.cv2.bn.weight  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv2.bn.bias  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv2.bn.running_mean  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv2.bn.running_var  Value:  torch.Size([256])  To numpy shape:  (256,)
Key:  model.23.m.0.cv2.bn.num_batches_tracked  Value:  torch.Size([])  To numpy shape:  ()
Key:  model.24.anchors  Value:  torch.Size([3, 3, 2])  To numpy shape:  (3, 3, 2)
Key:  model.24.anchor_grid  Value:  torch.Size([3, 1, 3, 1, 1, 2])  To numpy shape:  (3, 1, 3, 1, 1, 2)
Key:  model.24.m.0.weight  Value:  torch.Size([255, 128, 1, 1])  To numpy shape:  (255, 128, 1, 1)
Key:  model.24.m.0.bias  Value:  torch.Size([255])  To numpy shape:  (255,)
Key:  model.24.m.1.weight  Value:  torch.Size([255, 256, 1, 1])  To numpy shape:  (255, 256, 1, 1)
Key:  model.24.m.1.bias  Value:  torch.Size([255])  To numpy shape:  (255,)
Key:  model.24.m.2.weight  Value:  torch.Size([255, 512, 1, 1])  To numpy shape:  (255, 512, 1, 1)
Key:  model.24.m.2.bias  Value:  torch.Size([255])  To numpy shape:  (255,)
"""
